var localStoragelist = localStorage.getItem("listname")
if(localStoragelist) {
	localStoragelist = JSON.parse(localStoragelist);
} else {
	localStoragelist = [];
	localStorage.setItem('listname', []);
}
new Vue({
	el: 'body',
	data: {
		listname: '',
		listnum: '',
		list: localStoragelist,
		all: 20, //总页数
		cur: 1, //当前页码
	},
	methods: {
		add: function() {
			var name = this.listname;
			var count = this.listnum;
			if(name.length > 0 && count.length > 0) {
				var obj = {
					name: name,
					count: count,
				};
				this.list.push(obj);
				localStorage.setItem('listname', JSON.stringify(this.list));
				this.resed();
			}
		},
		resed: function() {
			this.listname = ""
			this.listnum = ""
		},
		del: function(index) {
			this.list.splice(index, 1);
			localStorage.setItem("listname", JSON.stringify(this.list))
		},
		delall: function() {
			this.list = [];
			localStorage.setItem("listname", JSON.stringify(this.list))
		},
		search: function() {
			//			this.list=[];
			console.log(JSON.stringify(localStorage.listname))
		}
	}
});